package com.inspectortime.service;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public abstract class AbstractZipCodeSearchService implements ZipCodeSearchService {
	
	public Set<String> findStatesByZipCodeRadiusInMiles(String zipCode, int radiusInMiles) {
		List<ZipCodeInfo> zipCodes = findNearbyZipCodes(zipCode, radiusInMiles);
		if (zipCodes != null && !zipCodes.isEmpty()){
			Set<String> nearbyStates = new HashSet<String>();
			for (ZipCodeInfo zipCodeInfo : zipCodes){
				nearbyStates.add(zipCodeInfo.getStateCode());
			}
			return nearbyStates;
		}
		return Collections.EMPTY_SET;
	}

}
